package o;

import com.google.gson.JsonSyntaxException;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public final class aue extends ato<Date> {
    public static final ats ˋ = new ats() {
        public <T> ato<T> ˎ(atb o_atb, auv<T> o_auv_T) {
            return o_auv_T.ˋ() == Date.class ? new aue() : null;
        }
    };
    private final List<DateFormat> ˎ = new ArrayList();

    public /* synthetic */ void ˎ(aux o_aux, Object obj) throws IOException {
        ˏ(o_aux, (Date) obj);
    }

    public /* synthetic */ Object ˏ(auy o_auy) throws IOException {
        return ˎ(o_auy);
    }

    public aue() {
        this.ˎ.add(DateFormat.getDateTimeInstance(2, 2, Locale.US));
        if (!Locale.getDefault().equals(Locale.US)) {
            this.ˎ.add(DateFormat.getDateTimeInstance(2, 2));
        }
        if (atx.ˋ()) {
            this.ˎ.add(aty.ॱ(2, 2));
        }
    }

    public Date ˎ(auy o_auy) throws IOException {
        if (o_auy.ʻ() != auz.NULL) {
            return ˏ(o_auy.ʽ());
        }
        o_auy.ॱॱ();
        return null;
    }

    private synchronized Date ˏ(String str) {
        Date parse;
        for (DateFormat parse2 : this.ˎ) {
            try {
                parse = parse2.parse(str);
                break;
            } catch (ParseException e) {
            }
        }
        try {
            parse = aus.ˋ(str, new ParsePosition(0));
        } catch (Throwable e2) {
            throw new JsonSyntaxException(str, e2);
        }
        return parse;
    }

    public synchronized void ˏ(aux o_aux, Date date) throws IOException {
        if (date == null) {
            o_aux.ᐝ();
        } else {
            o_aux.ˊ(((DateFormat) this.ˎ.get(0)).format(date));
        }
    }
}
